#ifndef _OD_SIP_SDP_H_
#define _OD_SIP_SDP_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <pjmedia/sdp.h>
#include <pjmedia/sdp_neg.h>
#include "od_sip_comn.h"


typedef struct 
{
    struct 
    {
        od_sip_session_type session_type;
        pjmedia_sdp_session *local_sdp;              /**< invite local send sdp*/
        pjmedia_sdp_session *remote_sdp;             /**< receive remote sdp from 200OK or INVITE, UPDATE, RE-INVITE*/
        pjmedia_sdp_session *local_capa;             /**< local capability */
        const pjmedia_sdp_session *active_local_sdp; /**< negotiate result local sdp*/
        const pjmedia_sdp_session *active_remote_sdp; /**< negotiate result remote sdp*/

        pj_bool_t match;                  /**< negotiate result! true:SUCCESS false: LOSS*/
    }session_sdp_neg;
    
    od_media_params decode_media;             /**< Contains parameters set to the decoder */
    od_media_params encode_media;             /**< Contains paramsters set to the endcoder */
    od_media_config *local_capa_config;       /**< local capability to generate a capa sdp*/
}od_sip_session_ctx;



/**
* Create initial SDP for a Call.
*
* @param ctx           od_sip context.
* @param buf           SDP in str.
* @param bufsize       this buf size.
* @param p_sdp         Pointer to receive the created SDP media.
* @param local_param   Func will create a Call SDP with this local parameter set.
*
* @return              PJ_SUCCESS on success, or the appropriate error code.
*/
pj_status_t od_media_create_initial_sdp(od_sip_ctx *ctx,
                                           char *buf,
                                           pj_size_t buf_size,
                                           pjmedia_sdp_session **p_sdp,
                                           const od_media_config *local_param);



/**
* SDP negotiate with remote peer-connection, server or endpoint.
*
* @param ctx                  od_sip context.
* @param remote_sdp           Socket information.
* @param remote_sdp_size      Option flags, must be zero for now.
* @param session_ctx                Pointer to receive the created SDP media.
*
* @return              PJ_SUCCESS on success, or the appropriate error code.
*/
pj_status_t od_media_sdp_negotiate(od_sip_ctx *ctx,
                                     char *remote_sdp,
                                     pj_size_t remote_sdp_size,
                                     od_sip_session_ctx *session_ctx);

                                     
/**
* Print SDP description to a buffer.
*
* @param sdp       The SDP session description.
* @param buf       The buffer.
* @param size      The buffer length.
*
* @return      the length printed, or -1 if the buffer is too
*          short.
*/
int od_media_sdp_print(const pjmedia_sdp_session *sdp, 
				        char *buf, 
				        pj_size_t size);

#ifdef __cplusplus
}
#endif

#endif

/*_*/

